<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@taglib prefix="l" uri="http://struts.apache.org/tags-logic" %>
<%@taglib prefix="b" uri="http://struts.apache.org/tags-bean" %>
<%@taglib prefix="h" uri="http://struts.apache.org/tags-html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<h1><b:message key="menu_users"/></h1>

<h:link styleClass="hidden createNew" action="/protected/dispatch?method=showCreateUserForm"><b:message key="user_create"/></h:link><br>

<div class="display sortableTable">
    <table width="100%" border="0" >
        <thead>
		<tr>
            <th scope="col"><b:message key="user_name"/></th>
            <th scope="col"><b:message key="user_username"/></th>
            <th scope="col"><b:message key="user_type"/></th>
            <th scope="col"><b:message key="gen_action"/></th>
        </tr>
<thead>
<tfoot>
<tr>
            <th scope="col"><b:message key="user_name"/></th>
            <th scope="col"><b:message key="user_username"/></th>
            <th scope="col"><b:message key="user_type"/></th>
            <th scope="col"><b:message key="gen_action"/></th>
        </tr>
</tfoot>
<tbody>
        <l:iterate id="user" name="showUsers.users" scope="request">
            <tr class="red1"><!--treba da ide red2 u svakom drugom-->
                <td><h:link action="/protected/dispatch?method=showUpdateUserForm"
                        paramId="uid" paramName="user" paramProperty="username">

                        <b:write name="user" property="firstName"/>
                        <b:write name="user" property="lastName"/>

                </h:link></td>
                <td><b:write name="user" property="username"/></td>
                <td>
                    <c:choose>
                        <c:when test="${user.type == 1}">
                            <b:message key="user_type_guest"/>
                        </c:when>

                        <c:when test="${user.type == 2}">
                            <b:message key="user_type_normal"/>
                        </c:when>

                        <c:otherwise>
                            <b:message key="user_type_admin"/>
                        </c:otherwise>
                    </c:choose>
                </td>
                <td><h:link styleClass="delete" action="/protected/dispatch?method=deleteUser"
                        paramId="uid" paramName="user" paramProperty="username" onclick="return confirm('Are you sure you want to delete this item?/Da li ste sigurni da zelite da izbrisete ovaj entitet?')"><b:message key="gen_delete"/></h:link>
                </td>
            </tr>
        </l:iterate>
		</tbody>
        
    </table>
</div><!--tabela-->
<script type="text/javascript">
function cancelForm(){
	$(".dialog").dialog('close');
}
</script>



